﻿using System;
using System;
using System.Collections.Generic;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Drawing;
using System.IO;
using System.Text;
using netDxf;
using netDxf.Blocks;
using netDxf.Collections;
using netDxf.Entities;
using netDxf.Header;
using netDxf.Objects;
using netDxf.Tables;
using netDxf.Units;
using Attribute = netDxf.Entities.Attribute;
using Image = netDxf.Entities.Image;
using Point = netDxf.Entities.Point;
using Trace = netDxf.Entities.Trace;
using System.Threading;

namespace TestDxfDocument
{

    class Threadendmillsolid
    {
        public static void _Threadendmillsolid(Dictionary<string, Object> data)//细柄丝锥
        {
            DxfDocument dxf = new DxfDocument();
            //图层
            Layer contour = new Layer("contour") { Color = AciColor.Cyan };    //轮廓层
            Layer dimensioning = new Layer("dimensioning");    //尺寸层
            Layer refin = new Layer("refin") { Color = AciColor.Red };    //基准线/内轮廓
            refin.Linetype = Linetype.Dashed;
            Layer centre = new Layer("centre") { Color = AciColor.Yellow };    //中心线
            Layer textlayer = new Layer("textlayer") { Color = AciColor.Blue };    //文本层
            Layer hatching = new Layer("hatching") { Color = AciColor.Blue };    //填充层
            centre.Linetype = Linetype.DashDot;
            Layer additionalline = new Layer("additionalline") { Color = AciColor.Cyan };    //附加线
            Layer cutting = new Layer("cutting") { Color = AciColor.Red };    //切削层
            Layer nocutting = new Layer("nocutting");    //非切削层
            Layer skcontour = new Layer("skcontour") { Color = AciColor.Cyan };    //sk轮廓层
            Layer skdimensioning = new Layer("skdimensioning");    //sk尺寸线层
            Layer skrefin = new Layer("skrefin") { Color = AciColor.Red };    //sk基准线/内轮廓
            Layer sktext = new Layer("sktext") { Color = AciColor.Blue };  //sk文本
            Layer skhatching = new Layer("skhatching") { Color = AciColor.Blue };    //sk填充
            Layer skadditionlline = new Layer("skadditionlline") { Color = AciColor.Cyan };    //sk附加线
            Layer skviewcontour = new Layer("skviewcontour") { Color = AciColor.Cyan };    //skview轮廓
            Layer skviewdimensioning = new Layer("skviewdimensioning");    //skview尺寸线层

            //参数
            double pi = Math.PI;
            string path = Convert.ToString(data["path"]);

            double scale = 2; //放大系数


            double oal = 34.36;
            double ls = 13.75;
            double dc = 7.97;
            double dn = 5.89;
            double dconms = 7.35;
            double lpr = 23.25;
            double tp = 1.32;
            double tg = 8;

            //坐标
            Vector2 v1 = new Vector2(0, 0);
            Vector2 v2 = new Vector2(v1.X - oal - 4, v1.Y);
            Vector2 v3 = new Vector2(v1.X - 2, v1.Y);
            Vector2 v4 = new Vector2(v3.X, v3.Y + dc / 2.393);
            Vector2 v5 = new Vector2(v4.X - tp / 2, v3.Y + dc / 2);
            Vector2 v6 = new Vector2(v4.X - tp, v4.Y);
            Vector2 v7 = new Vector2(v5.X - tp, v5.Y);
            Vector2 v8 = new Vector2(v6.X - tp, v6.Y);
            Vector2 v9 = new Vector2(v7.X - tp, v7.Y);
            Vector2 v10 = new Vector2(v8.X - tp, v8.Y);
            Vector2 v11 = new Vector2(v9.X - tp, v9.Y);
            Vector2 v12 = new Vector2(v10.X - tp, v10.Y);
            Vector2 v13 = new Vector2(v11.X - tp, v11.Y);
            Vector2 v14 = new Vector2(v12.X - tp, v12.Y);
            Vector2 v15 = new Vector2(v13.X - tp, v13.Y);
            Vector2 v16 = new Vector2(v14.X - tp, v14.Y);
            Vector2 v17 = new Vector2(v15.X - tp, v15.Y);
            Vector2 v18 = new Vector2(v17.X - tp / 2, v3.Y + dn / 2);
            Vector2 v19 = new Vector2(v4.X, v4.Y * -1);
            Vector2 v20 = new Vector2(v5.X, v5.Y * -1);
            Vector2 v21 = new Vector2(v7.X, v7.Y * -1);
            Vector2 v22 = new Vector2(v9.X, v9.Y * -1);
            Vector2 v23 = new Vector2(v11.X, v11.Y * -1);
            Vector2 v24 = new Vector2(v13.X, v13.Y * -1);
            Vector2 v25 = new Vector2(v15.X, v15.Y * -1);
            Vector2 v26 = new Vector2(v16.X, v16.Y * -1);
            Vector2 v27 = new Vector2(v17.X, v17.Y * -1);
            Vector2 v28 = new Vector2(v18.X, v18.Y * -1);
            Vector2 v41 = new Vector2(v6.X, v6.Y * -1);
            Vector2 v42 = new Vector2(v8.X, v8.Y * -1);
            Vector2 v43 = new Vector2(v10.X, v10.Y * -1);
            Vector2 v44 = new Vector2(v12.X, v12.Y * -1);
            Vector2 v45 = new Vector2(v14.X, v14.Y * -1);
            Vector2 v29 = new Vector2(v19.X, v19.Y + dc / 6.2265);
            Vector2 v30 = new Vector2(v20.X, v20.Y + dc / 6.871);
            Vector2 v31 = new Vector2(v41.X, v41.Y + dc / 7.0531);
            Vector2 v32 = new Vector2(v21.X, v21.Y + dc / 7.312);
            Vector2 v33 = new Vector2(v42.X, v42.Y + dc / 8.133);
            Vector2 v34 = new Vector2(v22.X, v22.Y + dc / 8.2165);
            Vector2 v35 = new Vector2(v43.X, v43.Y + dc / 12.453);
            Vector2 v36 = new Vector2(v23.X, v23.Y + dc / 10.77);
            Vector2 v37 = new Vector2(v44.X, v44.Y + dc / 15.327);
            Vector2 v38 = new Vector2(v24.X, v24.Y + dc / 13.982);
            Vector2 v39 = new Vector2(v45.X, v45.Y + dc / 17.711);
            Vector2 v40 = new Vector2(v25.X, v25.Y + dc / 16.604);
            Vector2 v49 = new Vector2(v2.X + 2, v2.Y - dconms / 2 + 0.5);
            Vector2 v48 = new Vector2(v49.X + 0.4, v2.Y - dconms / 2);
            Vector2 v47 = new Vector2(v49.X + ls, v48.Y);
            Vector2 v46 = new Vector2(v47.X + 0.5, v2.Y - dn / 2);
            Vector2 v50 = new Vector2(v49.X, v49.Y * -1);
            Vector2 v51 = new Vector2(v48.X, v48.Y * -1);
            Vector2 v52 = new Vector2(v47.X, v47.Y * -1);
            Vector2 v53 = new Vector2(v46.X, v46.Y * -1);
            Vector2 v54 = new Vector2(v3.X - lpr, v3.Y);
            Vector2 v55 = new Vector2(v54.X, v54.Y + dconms / 2 + 1);
            Vector2 v56 = new Vector2(v54.X, v54.Y - dconms / 2 - 1);
            Vector2 v57 = fun.Polar(v3, -176 * pi / 180, oal / 2.2026);
            Vector2 v58 = new Vector2(v57.X - oal / 190.889, v57.Y - dc / 19.925);
            Vector2 v59 = new Vector2(v58.X + oal / 18.983, v3.Y - dn / 2);
            Vector2 v60 = new Vector2(v3.X, v3.Y + dc / 4.1436);
            Vector2 v61 = new Vector2(v5.X, v60.Y + dc / 21.6389);
            Vector2 v62 = new Vector2(v6.X, v60.Y);
            Vector2 v63 = new Vector2(v7.X, v61.Y);
            Vector2 v64 = new Vector2(v8.X, v62.Y);
            Vector2 v65 = new Vector2(v9.X, v63.Y);
            Vector2 v66 = new Vector2(v10.X, v64.Y);
            Vector2 v67 = new Vector2(v11.X, v65.Y);
            Vector2 v68 = new Vector2(v12.X, v66.Y);
            Vector2 v69 = new Vector2(v13.X, v67.Y);
            Vector2 v70 = new Vector2(v14.X, v68.Y);
            Vector2 v71 = new Vector2(v15.X, v69.Y);
            Vector2 v72 = new Vector2(v16.X, v70.Y);
            Vector2 v73 = new Vector2(v17.X, v71.Y);
            Vector2 v74 = new Vector2(v18.X, v73.Y - dc / 29.961);
            Vector2 v75 = new Vector2(v74.X - oal / 11.5302, v74.Y - dc / 21.5405);
            Vector2 v76 = new Vector2(v75.X - oal / 9.388, v3.Y + dn / 2);
            Vector2 v77 = fun.Polar(v3, -176 * pi / 180, tp / 1.97);
            Vector2 v78 = fun.Polar(v77, -176 * pi / 180, tp / 1.97);
            Vector2 v79 = fun.Polar(v78, -176 * pi / 180, tp / 1.97);
            Vector2 v80 = fun.Polar(v79, -176 * pi / 180, tp / 1.97);
            Vector2 v81 = fun.Polar(v80, -176 * pi / 180, tp / 1.97);
            Vector2 v82 = fun.Polar(v81, -176 * pi / 180, tp / 1.97);
            Vector2 v83 = fun.Polar(v82, -176 * pi / 180, tp / 1.97);
            Vector2 v84 = fun.Polar(v83, -176 * pi / 180, tp / 1.97);
            Vector2 v85 = fun.Polar(v84, -176 * pi / 180, tp / 1.97);
            Vector2 v86 = fun.Polar(v85, -176 * pi / 180, tp / 1.97);
            Vector2 v87 = fun.Polar(v86, -176 * pi / 180, tp / 1.97);
            Vector2 v88 = fun.Polar(v87, -176 * pi / 180, tp / 1.97);
            Vector2 v89 = fun.Polar(v88, -176 * pi / 180, tp / 1.97);
            Vector2 v90 = fun.Polar(v89, -176 * pi / 180, tp / 1.97);
            Vector2 v196 = new Vector2(v19.X - oal / 14.437, v19.Y + oal / 17.18);
            Vector2 v197 = new Vector2(v196.X + oal / 7.295, v196.Y);
            Vector2 v198 = new Vector2(v197.X, v197.Y - oal / 8.611);
            Vector2 v199 = new Vector2(v196.X, v198.Y);

            Vector2 v91 = new Vector2(v2.X + oal / 6.103, v2.Y - oal / 1.138);
            Vector2 v92 = new Vector2(v91.X - tp / 2 * scale, v91.Y - (v5.Y - v4.Y) * scale);
            Vector2 v93 = new Vector2(v91.X - tp * scale, v91.Y);
            Vector2 v94 = new Vector2(v92.X - tp * scale, v92.Y);
            Vector2 v95 = new Vector2(v93.X - tp * scale, v93.Y);
            Vector2 v96 = new Vector2(v94.X - tp * scale, v94.Y);
            Vector2 v97 = new Vector2(v95.X - tp * scale, v95.Y);
            Vector2 v98 = new Vector2(v91.X, v91.Y + dc / 1.177);
            Vector2 v99 = new Vector2(v91.X, v91.Y + dc / 6.2265);
            Vector2 v100 = new Vector2(v92.X, v92.Y + dc / 6.871);
            Vector2 v101 = new Vector2(v93.X, v93.Y + dc / 7.0531);
            Vector2 v102 = new Vector2(v94.X, v94.Y + dc / 7.312);
            Vector2 v103 = new Vector2(v95.X, v95.Y + dc / 8.133);
            Vector2 v104 = new Vector2(v96.X, v96.Y + dc / 8.2165);
            Vector2 v105 = new Vector2(v97.X, v97.Y + dc / 12.453);
            Vector2 v106 = new Vector2(v105.X, v98.Y);
            Vector2 v107 = new Vector2(v106.X + dc / 0.455, v106.Y);
            Vector2 v108 = new Vector2(v107.X, v107.Y - dc / 0.455);
            Vector2 v109 = new Vector2(v106.X, v108.Y);

            Vector2 v110 = new Vector2(v3.X, v3.Y - oal / 0.95);
            Vector2 a110 = new Vector2(v2.X, v3.Y - oal / 0.95);
            Vector2 v111 = fun.Polar(v110, -176 * pi / 180, oal / 2.643);
            Vector2 v112 = new Vector2(v110.X, v110.Y + dc / 2.393);
            Vector2 v113 = new Vector2(v112.X - tp / 2, v110.Y + dc / 2);
            Vector2 v114 = fun.Polar(v112, (180 - tg / 2) * pi / 180, tp / Math.Cos(tg / 2 * pi / 180));
            Vector2 v115 = fun.Polar(v113, (180 - tg / 2) * pi / 180, tp / Math.Cos(tg / 2 * pi / 180));
            Vector2 v116 = fun.Polar(v114, (180 - tg / 2) * pi / 180, tp / Math.Cos(tg / 2 * pi / 180));
            Vector2 v117 = fun.Polar(v115, (180 - tg / 2) * pi / 180, tp / Math.Cos(tg / 2 * pi / 180));
            Vector2 v118 = fun.Polar(v116, (180 - tg / 2) * pi / 180, tp / Math.Cos(tg / 2 * pi / 180));
            Vector2 v119 = fun.Polar(v117, (180 - tg / 2) * pi / 180, tp / Math.Cos(tg / 2 * pi / 180));
            Vector2 v120 = fun.Polar(v118, (180 - tg / 2) * pi / 180, tp / Math.Cos(tg / 2 * pi / 180));
            Vector2 v121 = fun.Polar(v119, (180 - tg / 2) * pi / 180, tp / Math.Cos(tg / 2 * pi / 180));
            Vector2 v122 = fun.Polar(v120, (180 - tg / 2) * pi / 180, tp / Math.Cos(tg / 2 * pi / 180));
            Vector2 v123 = fun.Polar(v121, (180 - tg / 2) * pi / 180, tp / Math.Cos(tg / 2 * pi / 180));
            Vector2 v124 = fun.Polar(v122, (180 - tg / 2) * pi / 180, tp / Math.Cos(tg / 2 * pi / 180));
            Vector2 v125 = fun.Polar(v123, (180 - tg / 2) * pi / 180, tp / Math.Cos(tg / 2 * pi / 180));
            Vector2 v126 = new Vector2(v125.X - tp / 2, v125.Y - dc / 8.05);
            Vector2 v127 = new Vector2(v126.X, v126.Y - dc / 13.644);
            Vector2 v128 = new Vector2(v127.X - oal / 7.421, v127.Y);
            Vector2 v129 = fun.mirrorpoint(v112, v110, a110);
            Vector2 v130 = fun.mirrorpoint(v113, v110, a110);
            Vector2 v131 = fun.mirrorpoint(v114, v110, a110);
            Vector2 v132 = fun.mirrorpoint(v115, v110, a110);
            Vector2 v133 = fun.mirrorpoint(v116, v110, a110);
            Vector2 v134 = fun.mirrorpoint(v117, v110, a110);
            Vector2 v135 = fun.mirrorpoint(v118, v110, a110);
            Vector2 v136 = fun.mirrorpoint(v119, v110, a110);
            Vector2 v137 = fun.mirrorpoint(v120, v110, a110);
            Vector2 v138 = fun.mirrorpoint(v121, v110, a110);
            Vector2 v139 = fun.mirrorpoint(v122, v110, a110);
            Vector2 v140 = fun.mirrorpoint(v123, v110, a110);
            Vector2 v141 = fun.mirrorpoint(v124, v110, a110);
            Vector2 v142 = fun.mirrorpoint(v125, v110, a110);
            Vector2 v143 = fun.mirrorpoint(v126, v110, a110);
            Vector2 v144 = fun.mirrorpoint(v127, v110, a110);
            Vector2 v145 = new Vector2(v144.X - oal / 8.765, v144.Y);
            Vector2 v146 = new Vector2(v110.X, v110.Y + dc / 4.1436);
            Vector2 v147 = new Vector2(v113.X, v146.Y + dc / 21.6389);
            Vector2 v148 = new Vector2(v114.X, v146.Y);
            Vector2 v149 = new Vector2(v115.X, v147.Y);
            Vector2 v150 = new Vector2(v116.X, v148.Y);
            Vector2 v151 = new Vector2(v117.X, v149.Y);
            Vector2 v152 = new Vector2(v118.X, v150.Y);
            Vector2 v153 = new Vector2(v119.X, v151.Y);
            Vector2 v154 = new Vector2(v120.X, v152.Y);
            Vector2 v155 = new Vector2(v121.X, v153.Y);
            Vector2 v156 = new Vector2(v122.X, v154.Y);
            Vector2 v157 = new Vector2(v123.X, v155.Y);
            Vector2 v158 = new Vector2(v124.X, v156.Y);
            Vector2 v159 = new Vector2(v125.X, v157.Y);
            Vector2 v160 = new Vector2(v126.X, v159.Y - dc / 29.961);
            Vector2 v161 = new Vector2(v160.X - oal / 11.5302, v160.Y - dc / 21.5405);
            Vector2 v162 = new Vector2(v161.X - oal / 20.6988, v161.Y + dc / 20.125);
            Vector2 v163 = fun.Polar(v110, -176 * pi / 180, tp / 1.97);
            Vector2 v164 = fun.Polar(v163, -176 * pi / 180, tp / 1.97);
            Vector2 v165 = fun.Polar(v164, -176 * pi / 180, tp / 1.97);
            Vector2 v166 = fun.Polar(v165, -176 * pi / 180, tp / 1.97);
            Vector2 v167 = fun.Polar(v166, -176 * pi / 180, tp / 1.97);
            Vector2 v168 = fun.Polar(v167, -176 * pi / 180, tp / 1.97);
            Vector2 v169 = fun.Polar(v168, -176 * pi / 180, tp / 1.97);
            Vector2 v170 = fun.Polar(v169, -176 * pi / 180, tp / 1.97);
            Vector2 v171 = fun.Polar(v170, -176 * pi / 180, tp / 1.97);
            Vector2 v172 = fun.Polar(v171, -176 * pi / 180, tp / 1.97);
            Vector2 v173 = fun.Polar(v172, -176 * pi / 180, tp / 1.97);
            Vector2 v174 = fun.Polar(v173, -176 * pi / 180, tp / 1.97);
            Vector2 v175 = fun.Polar(v174, -176 * pi / 180, tp / 1.97);
            Vector2 v176 = fun.Polar(v175, -176 * pi / 180, tp / 1.97);
            Vector2 v177 = new Vector2(v129.X, v129.Y + dc / 6.2265);
            Vector2 v178 = new Vector2(v130.X, v130.Y + dc / 6.871);
            Vector2 v179 = new Vector2(v131.X, v131.Y + dc / 7.0531);
            Vector2 v180 = new Vector2(v132.X, v132.Y + dc / 7.312);
            Vector2 v181 = new Vector2(v133.X, v133.Y + dc / 8.133);
            Vector2 v182 = new Vector2(v134.X, v134.Y + dc / 8.2165);
            Vector2 v183 = new Vector2(v135.X, v135.Y + dc / 12.453);
            Vector2 v184 = new Vector2(v136.X, v136.Y + dc / 10.77);
            Vector2 v185 = new Vector2(v137.X, v137.Y + dc / 15.327);
            Vector2 v186 = new Vector2(v138.X, v138.Y + dc / 13.982);
            Vector2 v187 = new Vector2(v139.X, v139.Y + dc / 17.711);
            Vector2 v188 = new Vector2(v140.X, v140.Y + dc / 16.604);
            Vector2 v189 = new Vector2(v128.X + oal / 49.797, v128.Y + dc / 6.389);
            Vector2 v190 = new Vector2(v162.X + oal / 68.72, v162.Y - dc / 4.969);
            Vector2 v191 = new Vector2(v145.X - oal / 32.112, v145.Y - dc / 5.127);
            Vector2 v192 = new Vector2(v110.X - oal / 1.777, v110.Y + oal / 2.0637);
            Vector2 v193 = new Vector2(v192.X + oal / 1.268, v192.Y);
            Vector2 v194 = new Vector2(v193.X, v193.Y - oal / 1.086);
            Vector2 v195 = new Vector2(v192.X, v194.Y);
             

            //作图
            //1
            Line line1 = new Line(v1, v2);
            line1.Layer = centre;
            line1.Linetype = Linetype.DashDot;
            line1.LinetypeScale = 3;
            dxf.AddEntity(line1);

            Line line2 = new Line(v55, v56);
            line2.Layer = centre;
            line2.Linetype = Linetype.DashDot;
            line2.LinetypeScale = 3;
            dxf.AddEntity(line2);

            Line line26 = new Line(v198, v197);
            line26.Layer = refin;
            line26.Linetype = Linetype.Dashed;
            line26.LinetypeScale = 5;
            dxf.AddEntity(line26);

            Line line27 = new Line(v198, v199);
            line27.Layer = refin;
            line27.Linetype = Linetype.Dashed;
            line27.LinetypeScale = 5;
            dxf.AddEntity(line27);

            Line line28 = new Line(v199, v196);
            line28.Layer = refin;
            line28.Linetype = Linetype.Dashed;
            line28.LinetypeScale = 5;
            dxf.AddEntity(line28);

            Line line29 = new Line(v196, v197);
            line29.Layer = refin;
            line29.Linetype = Linetype.Dashed;
            line29.LinetypeScale = 5;
            dxf.AddEntity(line29);

            LwPolyline line3 = new LwPolyline();
            line3.Vertexes.Add(new LwPolylineVertex(v4));
            line3.Vertexes.Add(new LwPolylineVertex(v5));
            line3.Vertexes.Add(new LwPolylineVertex(v6));
            line3.Vertexes.Add(new LwPolylineVertex(v7));
            line3.Vertexes.Add(new LwPolylineVertex(v8));
            line3.Vertexes.Add(new LwPolylineVertex(v9));
            line3.Vertexes.Add(new LwPolylineVertex(v10));
            line3.Vertexes.Add(new LwPolylineVertex(v11));
            line3.Vertexes.Add(new LwPolylineVertex(v12));
            line3.Vertexes.Add(new LwPolylineVertex(v13));
            line3.Vertexes.Add(new LwPolylineVertex(v14));
            line3.Vertexes.Add(new LwPolylineVertex(v15));
            line3.Vertexes.Add(new LwPolylineVertex(v16));
            line3.Vertexes.Add(new LwPolylineVertex(v17));
            line3.Vertexes.Add(new LwPolylineVertex(v18));
            line3.Vertexes.Add(new LwPolylineVertex(v53));
            line3.Vertexes.Add(new LwPolylineVertex(v46));
            line3.Vertexes.Add(new LwPolylineVertex(v28));
            line3.Vertexes.Add(new LwPolylineVertex(v27));
            line3.Vertexes.Add(new LwPolylineVertex(v26));
            line3.Vertexes.Add(new LwPolylineVertex(v25));
            line3.Vertexes.Add(new LwPolylineVertex(v45));
            line3.Vertexes.Add(new LwPolylineVertex(v24));
            line3.Vertexes.Add(new LwPolylineVertex(v44));
            line3.Vertexes.Add(new LwPolylineVertex(v23));
            line3.Vertexes.Add(new LwPolylineVertex(v43));
            line3.Vertexes.Add(new LwPolylineVertex(v22));
            line3.Vertexes.Add(new LwPolylineVertex(v42));
            line3.Vertexes.Add(new LwPolylineVertex(v21));
            line3.Vertexes.Add(new LwPolylineVertex(v41));
            line3.Vertexes.Add(new LwPolylineVertex(v20));
            line3.Vertexes.Add(new LwPolylineVertex(v19));
            line3.Vertexes.Add(new LwPolylineVertex(v4));
            fun.PolyFill(dxf, line3, 0.1, contour);

            LwPolyline line4 = new LwPolyline();
            line4.Vertexes.Add(new LwPolylineVertex(v29));
            line4.Vertexes.Add(new LwPolylineVertex(v30));
            line4.Vertexes.Add(new LwPolylineVertex(v31));
            line4.Vertexes.Add(new LwPolylineVertex(v32));
            line4.Vertexes.Add(new LwPolylineVertex(v33));
            line4.Vertexes.Add(new LwPolylineVertex(v34));
            line4.Vertexes.Add(new LwPolylineVertex(v35));
            line4.Vertexes.Add(new LwPolylineVertex(v36));
            line4.Vertexes.Add(new LwPolylineVertex(v37));
            line4.Vertexes.Add(new LwPolylineVertex(v38));
            line4.Vertexes.Add(new LwPolylineVertex(v39));
            line4.Vertexes.Add(new LwPolylineVertex(v40));
            line4.Vertexes.Add(new LwPolylineVertex(v26));
            fun.PolyFill(dxf, line4, 0.1, contour);

            LwPolyline line5 = new LwPolyline();
            line5.Vertexes.Add(new LwPolylineVertex(v20));
            line5.Vertexes.Add(new LwPolylineVertex(v30));
            line5.Vertexes.Add(new LwPolylineVertex(v31));
            line5.Vertexes.Add(new LwPolylineVertex(v41));
            line5.Vertexes.Add(new LwPolylineVertex(v21));
            line5.Vertexes.Add(new LwPolylineVertex(v32));
            line5.Vertexes.Add(new LwPolylineVertex(v33));
            line5.Vertexes.Add(new LwPolylineVertex(v42));
            line5.Vertexes.Add(new LwPolylineVertex(v22));
            line5.Vertexes.Add(new LwPolylineVertex(v34));
            line5.Vertexes.Add(new LwPolylineVertex(v35));
            line5.Vertexes.Add(new LwPolylineVertex(v43));
            line5.Vertexes.Add(new LwPolylineVertex(v23));
            line5.Vertexes.Add(new LwPolylineVertex(v36));
            line5.Vertexes.Add(new LwPolylineVertex(v37));
            line5.Vertexes.Add(new LwPolylineVertex(v44));
            line5.Vertexes.Add(new LwPolylineVertex(v24));
            line5.Vertexes.Add(new LwPolylineVertex(v38));
            line5.Vertexes.Add(new LwPolylineVertex(v39));
            line5.Vertexes.Add(new LwPolylineVertex(v45));
            line5.Vertexes.Add(new LwPolylineVertex(v25));
            line5.Vertexes.Add(new LwPolylineVertex(v40));
            fun.PolyFill(dxf, line5, 0.1, contour);

            LwPolyline line6 = new LwPolyline();
            line6.Vertexes.Add(new LwPolylineVertex(v53));
            line6.Vertexes.Add(new LwPolylineVertex(v52));
            line6.Vertexes.Add(new LwPolylineVertex(v51));
            line6.Vertexes.Add(new LwPolylineVertex(v50));
            line6.Vertexes.Add(new LwPolylineVertex(v49));
            line6.Vertexes.Add(new LwPolylineVertex(v48));
            line6.Vertexes.Add(new LwPolylineVertex(v47));
            line6.Vertexes.Add(new LwPolylineVertex(v46));
            line6.Vertexes.Add(new LwPolylineVertex(v47));
            line6.Vertexes.Add(new LwPolylineVertex(v52));
            line6.Vertexes.Add(new LwPolylineVertex(v51));
            line6.Vertexes.Add(new LwPolylineVertex(v48));
            fun.PolyFill(dxf, line6, 0.1, contour);

            LwPolyline line7 = new LwPolyline();
            line7.Vertexes.Add(new LwPolylineVertex(v60));
            line7.Vertexes.Add(new LwPolylineVertex(v61));
            line7.Vertexes.Add(new LwPolylineVertex(v62));
            line7.Vertexes.Add(new LwPolylineVertex(v63));
            line7.Vertexes.Add(new LwPolylineVertex(v64));
            line7.Vertexes.Add(new LwPolylineVertex(v65));
            line7.Vertexes.Add(new LwPolylineVertex(v66));
            line7.Vertexes.Add(new LwPolylineVertex(v67));
            line7.Vertexes.Add(new LwPolylineVertex(v68));
            line7.Vertexes.Add(new LwPolylineVertex(v69));
            line7.Vertexes.Add(new LwPolylineVertex(v70));
            line7.Vertexes.Add(new LwPolylineVertex(v71));
            line7.Vertexes.Add(new LwPolylineVertex(v72));
            line7.Vertexes.Add(new LwPolylineVertex(v73));
            line7.Vertexes.Add(new LwPolylineVertex(v74));
            line7.Vertexes.Add(new LwPolylineVertex(v75));
            line7.Vertexes.Add(new LwPolylineVertex(v76));
            line7.Vertexes[15].Bulge = Math.Tan(-53 * pi / 180 / 4);
            fun.PolyFill(dxf, line7, 0.1, contour);

            LwPolyline line8 = new LwPolyline();
            line8.Vertexes.Add(new LwPolylineVertex(v3));
            line8.Vertexes.Add(new LwPolylineVertex(v57));
            line8.Vertexes.Add(new LwPolylineVertex(v58));
            line8.Vertexes.Add(new LwPolylineVertex(v59));
            line8.Vertexes[1].Bulge = Math.Tan(114 * pi / 180 / 4);
            line8.Vertexes[2].Bulge = Math.Tan(30 * pi / 180 / 4);
            fun.PolyFill(dxf, line8, 0.1, contour);

            LwPolyline line9 = new LwPolyline();
            line9.Vertexes.Add(new LwPolylineVertex(v61));
            line9.Vertexes.Add(new LwPolylineVertex(v77));
            line9.Vertexes.Add(new LwPolylineVertex(v78));
            line9.Vertexes.Add(new LwPolylineVertex(v62));
            line9.Vertexes.Add(new LwPolylineVertex(v63));
            line9.Vertexes.Add(new LwPolylineVertex(v79));
            line9.Vertexes.Add(new LwPolylineVertex(v80));
            line9.Vertexes.Add(new LwPolylineVertex(v64));
            line9.Vertexes.Add(new LwPolylineVertex(v65));
            line9.Vertexes.Add(new LwPolylineVertex(v81));
            line9.Vertexes.Add(new LwPolylineVertex(v82));
            line9.Vertexes.Add(new LwPolylineVertex(v66));
            line9.Vertexes.Add(new LwPolylineVertex(v67));
            line9.Vertexes.Add(new LwPolylineVertex(v83));
            line9.Vertexes.Add(new LwPolylineVertex(v84));
            line9.Vertexes.Add(new LwPolylineVertex(v68));
            line9.Vertexes.Add(new LwPolylineVertex(v69));
            line9.Vertexes.Add(new LwPolylineVertex(v85));
            line9.Vertexes.Add(new LwPolylineVertex(v86));
            line9.Vertexes.Add(new LwPolylineVertex(v70));
            line9.Vertexes.Add(new LwPolylineVertex(v71));
            line9.Vertexes.Add(new LwPolylineVertex(v87));
            line9.Vertexes.Add(new LwPolylineVertex(v88));
            line9.Vertexes.Add(new LwPolylineVertex(v72));
            line9.Vertexes.Add(new LwPolylineVertex(v73));
            line9.Vertexes.Add(new LwPolylineVertex(v89));
            line9.Vertexes.Add(new LwPolylineVertex(v90));
            line9.Vertexes.Add(new LwPolylineVertex(v74));
            fun.PolyFill(dxf, line9, 0.1, contour);

            //2
            Line line10 = new Line(v106, v107);
            line10.Layer = refin;
            line10.Linetype = Linetype.Dashed;
            line10.LinetypeScale = 5;
            dxf.AddEntity(line10);

            Line line11 = new Line(v108, v107);
            line11.Layer = refin;
            line11.Linetype = Linetype.Dashed;
            line11.LinetypeScale = 5;
            dxf.AddEntity(line11);

            Line line12 = new Line(v106, v109);
            line12.Layer = refin;
            line12.Linetype = Linetype.Dashed;
            line12.LinetypeScale = 5;
            dxf.AddEntity(line12);

            Line line13 = new Line(v108, v109);
            line13.Layer = refin;
            line13.Linetype = Linetype.Dashed;
            line13.LinetypeScale = 5;
            dxf.AddEntity(line13);

            LwPolyline line14 = new LwPolyline();
            line14.Vertexes.Add(new LwPolylineVertex(v98));
            line14.Vertexes.Add(new LwPolylineVertex(v91));
            line14.Vertexes.Add(new LwPolylineVertex(v92));
            line14.Vertexes.Add(new LwPolylineVertex(v93));
            line14.Vertexes.Add(new LwPolylineVertex(v94));
            line14.Vertexes.Add(new LwPolylineVertex(v95));
            line14.Vertexes.Add(new LwPolylineVertex(v96));
            line14.Vertexes.Add(new LwPolylineVertex(v97));
            fun.PolyFill(dxf, line14, 0.1, contour);

            LwPolyline line15 = new LwPolyline();
            line15.Vertexes.Add(new LwPolylineVertex(v99));
            line15.Vertexes.Add(new LwPolylineVertex(v100));
            line15.Vertexes.Add(new LwPolylineVertex(v101));
            line15.Vertexes.Add(new LwPolylineVertex(v102));
            line15.Vertexes.Add(new LwPolylineVertex(v103));
            line15.Vertexes.Add(new LwPolylineVertex(v104));
            line15.Vertexes.Add(new LwPolylineVertex(v105));
            fun.PolyFill(dxf, line15, 0.1, contour);

            LwPolyline line16 = new LwPolyline();
            line16.Vertexes.Add(new LwPolylineVertex(v100));
            line16.Vertexes.Add(new LwPolylineVertex(v92));
            line16.Vertexes.Add(new LwPolylineVertex(v93));
            line16.Vertexes.Add(new LwPolylineVertex(v101));
            line16.Vertexes.Add(new LwPolylineVertex(v102));
            line16.Vertexes.Add(new LwPolylineVertex(v94));
            line16.Vertexes.Add(new LwPolylineVertex(v95));
            line16.Vertexes.Add(new LwPolylineVertex(v103));
            line16.Vertexes.Add(new LwPolylineVertex(v104));
            line16.Vertexes.Add(new LwPolylineVertex(v96));
            fun.PolyFill(dxf, line16, 0.1, contour);

            //3
            LwPolyline line17 = new LwPolyline();
            line17.Vertexes.Add(new LwPolylineVertex(v128));
            line17.Vertexes.Add(new LwPolylineVertex(v127));
            line17.Vertexes.Add(new LwPolylineVertex(v126));
            line17.Vertexes.Add(new LwPolylineVertex(v125));
            line17.Vertexes.Add(new LwPolylineVertex(v124));
            line17.Vertexes.Add(new LwPolylineVertex(v123));
            line17.Vertexes.Add(new LwPolylineVertex(v122));
            line17.Vertexes.Add(new LwPolylineVertex(v121));
            line17.Vertexes.Add(new LwPolylineVertex(v120));
            line17.Vertexes.Add(new LwPolylineVertex(v119));
            line17.Vertexes.Add(new LwPolylineVertex(v118));
            line17.Vertexes.Add(new LwPolylineVertex(v117));
            line17.Vertexes.Add(new LwPolylineVertex(v116));
            line17.Vertexes.Add(new LwPolylineVertex(v115));
            line17.Vertexes.Add(new LwPolylineVertex(v114));
            line17.Vertexes.Add(new LwPolylineVertex(v113));
            line17.Vertexes.Add(new LwPolylineVertex(v112));
            line17.Vertexes.Add(new LwPolylineVertex(v129));
            line17.Vertexes.Add(new LwPolylineVertex(v130));
            line17.Vertexes.Add(new LwPolylineVertex(v131));
            line17.Vertexes.Add(new LwPolylineVertex(v132));
            line17.Vertexes.Add(new LwPolylineVertex(v133));
            line17.Vertexes.Add(new LwPolylineVertex(v134));
            line17.Vertexes.Add(new LwPolylineVertex(v135));
            line17.Vertexes.Add(new LwPolylineVertex(v136));
            line17.Vertexes.Add(new LwPolylineVertex(v137));
            line17.Vertexes.Add(new LwPolylineVertex(v138));
            line17.Vertexes.Add(new LwPolylineVertex(v139));
            line17.Vertexes.Add(new LwPolylineVertex(v140));
            line17.Vertexes.Add(new LwPolylineVertex(v141));
            line17.Vertexes.Add(new LwPolylineVertex(v142));
            line17.Vertexes.Add(new LwPolylineVertex(v143));
            line17.Vertexes.Add(new LwPolylineVertex(v144));
            line17.Vertexes.Add(new LwPolylineVertex(v145));
            fun.PolyFill(dxf, line17, 0.1, contour);

            LwPolyline line18 = new LwPolyline();
            line18.Vertexes.Add(new LwPolylineVertex(v146));
            line18.Vertexes.Add(new LwPolylineVertex(v147));
            line18.Vertexes.Add(new LwPolylineVertex(v148));
            line18.Vertexes.Add(new LwPolylineVertex(v149));
            line18.Vertexes.Add(new LwPolylineVertex(v150));
            line18.Vertexes.Add(new LwPolylineVertex(v151));
            line18.Vertexes.Add(new LwPolylineVertex(v152));
            line18.Vertexes.Add(new LwPolylineVertex(v153));
            line18.Vertexes.Add(new LwPolylineVertex(v154));
            line18.Vertexes.Add(new LwPolylineVertex(v155));
            line18.Vertexes.Add(new LwPolylineVertex(v156));
            line18.Vertexes.Add(new LwPolylineVertex(v157));
            line18.Vertexes.Add(new LwPolylineVertex(v158));
            line18.Vertexes.Add(new LwPolylineVertex(v159));
            line18.Vertexes.Add(new LwPolylineVertex(v160));
            line18.Vertexes.Add(new LwPolylineVertex(v161));
            line18.Vertexes.Add(new LwPolylineVertex(v162));
            line18.Vertexes[15].Bulge = Math.Tan(-53 * pi / 180 / 4);
            fun.PolyFill(dxf, line18, 0.1, contour);

            LwPolyline line19 = new LwPolyline();
            line19.Vertexes.Add(new LwPolylineVertex(v111));
            line19.Vertexes.Add(new LwPolylineVertex(v110));
            line19.Vertexes.Add(new LwPolylineVertex(v163));
            line19.Vertexes.Add(new LwPolylineVertex(v147));
            line19.Vertexes.Add(new LwPolylineVertex(v148));
            line19.Vertexes.Add(new LwPolylineVertex(v164));
            line19.Vertexes.Add(new LwPolylineVertex(v165));
            line19.Vertexes.Add(new LwPolylineVertex(v149));
            line19.Vertexes.Add(new LwPolylineVertex(v150));
            line19.Vertexes.Add(new LwPolylineVertex(v166));
            line19.Vertexes.Add(new LwPolylineVertex(v167));
            line19.Vertexes.Add(new LwPolylineVertex(v151));
            line19.Vertexes.Add(new LwPolylineVertex(v152));
            line19.Vertexes.Add(new LwPolylineVertex(v168));
            line19.Vertexes.Add(new LwPolylineVertex(v169));
            line19.Vertexes.Add(new LwPolylineVertex(v153));
            line19.Vertexes.Add(new LwPolylineVertex(v169));
            line19.Vertexes.Add(new LwPolylineVertex(v170));
            line19.Vertexes.Add(new LwPolylineVertex(v154));
            line19.Vertexes.Add(new LwPolylineVertex(v155));
            line19.Vertexes.Add(new LwPolylineVertex(v171));
            line19.Vertexes.Add(new LwPolylineVertex(v155));
            line19.Vertexes.Add(new LwPolylineVertex(v156));
            line19.Vertexes.Add(new LwPolylineVertex(v172));
            line19.Vertexes.Add(new LwPolylineVertex(v173));
            line19.Vertexes.Add(new LwPolylineVertex(v157));
            line19.Vertexes.Add(new LwPolylineVertex(v158));
            line19.Vertexes.Add(new LwPolylineVertex(v174));
            line19.Vertexes.Add(new LwPolylineVertex(v175));
            line19.Vertexes.Add(new LwPolylineVertex(v159));
            line19.Vertexes.Add(new LwPolylineVertex(v160));
            line19.Vertexes.Add(new LwPolylineVertex(v176));
            fun.PolyFill(dxf, line19, 0.1, contour);

            LwPolyline line20 = new LwPolyline();
            line20.Vertexes.Add(new LwPolylineVertex(v177));
            line20.Vertexes.Add(new LwPolylineVertex(v178));
            line20.Vertexes.Add(new LwPolylineVertex(v179));
            line20.Vertexes.Add(new LwPolylineVertex(v180));
            line20.Vertexes.Add(new LwPolylineVertex(v181));
            line20.Vertexes.Add(new LwPolylineVertex(v182));
            line20.Vertexes.Add(new LwPolylineVertex(v183));
            line20.Vertexes.Add(new LwPolylineVertex(v184));
            line20.Vertexes.Add(new LwPolylineVertex(v185));
            line20.Vertexes.Add(new LwPolylineVertex(v186));
            line20.Vertexes.Add(new LwPolylineVertex(v187));
            line20.Vertexes.Add(new LwPolylineVertex(v188));
            line20.Vertexes.Add(new LwPolylineVertex(v141));
            line20.Vertexes.Add(new LwPolylineVertex(v140));
            line20.Vertexes.Add(new LwPolylineVertex(v188));
            line20.Vertexes.Add(new LwPolylineVertex(v187));
            line20.Vertexes.Add(new LwPolylineVertex(v139));
            line20.Vertexes.Add(new LwPolylineVertex(v138));
            line20.Vertexes.Add(new LwPolylineVertex(v186));
            line20.Vertexes.Add(new LwPolylineVertex(v185));
            line20.Vertexes.Add(new LwPolylineVertex(v137));
            line20.Vertexes.Add(new LwPolylineVertex(v136));
            line20.Vertexes.Add(new LwPolylineVertex(v184));
            line20.Vertexes.Add(new LwPolylineVertex(v183));
            line20.Vertexes.Add(new LwPolylineVertex(v135));
            line20.Vertexes.Add(new LwPolylineVertex(v134));
            line20.Vertexes.Add(new LwPolylineVertex(v182));
            line20.Vertexes.Add(new LwPolylineVertex(v181));
            line20.Vertexes.Add(new LwPolylineVertex(v133));
            line20.Vertexes.Add(new LwPolylineVertex(v132));
            line20.Vertexes.Add(new LwPolylineVertex(v180));
            line20.Vertexes.Add(new LwPolylineVertex(v179));
            line20.Vertexes.Add(new LwPolylineVertex(v131));
            line20.Vertexes.Add(new LwPolylineVertex(v130));
            line20.Vertexes.Add(new LwPolylineVertex(v178));
            fun.PolyFill(dxf, line20, 0.1, contour);

            Arc c1 = fun.DrawArc3(v189, v128, v162);
            fun.drawBArc(dxf, c1, 0.1, contour);

            Arc c2 = fun.DrawArc3(v191, v145, v111);
            fun.drawBArc(dxf, c2, 0.1, contour);

            LwPolyline line21 = new LwPolyline();
            line21.Vertexes.Add(new LwPolylineVertex(v162));
            line21.Vertexes.Add(new LwPolylineVertex(v190));
            line21.Vertexes.Add(new LwPolylineVertex(v111));
            line21.Vertexes[0].Bulge = Math.Tan(2 * pi / 180 / 4);
            line21.Vertexes[1].Bulge = Math.Tan(-2 * pi / 180 / 4);
            fun.PolyFill(dxf, line21, 0.1, contour);

            Line line22 = new Line(v192, v193);
            line22.Layer = refin;
            line22.Linetype = Linetype.Dashed;
            line22.LinetypeScale = 5;
            dxf.AddEntity(line22);

            Line line23 = new Line(v194, v193);
            line23.Layer = refin;
            line23.Linetype = Linetype.Dashed;
            line23.LinetypeScale = 5;
            dxf.AddEntity(line23);

            Line line24 = new Line(v192, v195);
            line24.Layer = refin;
            line24.Linetype = Linetype.Dashed;
            line24.LinetypeScale = 5;
            dxf.AddEntity(line24);

            Line line25 = new Line(v194, v195);
            line25.Layer = refin;
            line25.Linetype = Linetype.Dashed;
            line25.LinetypeScale = 5;
            dxf.AddEntity(line25);


            //坐标系
            fun.Axis(dxf, new Vector2 (v2.X +2,v2.Y), -90, 180, "", "", "", 0.3, 1, 0);

            fun.Axis(dxf, v54, -90, 180, "", "", "", 0.3, 1, 0);

            fun.Axis(dxf, v3, -90, 180, "", "", "", 0.3, 1, 0);

            fun.Axis(dxf, v110, -90, 180, "", "", "", 0.3, 1, 0);



            //标注

            double height = 2;
            double arrowsize = 2;
            double exline = 2;


            //1
            fun.dimrot1(dxf, v50, v4, 0, dconms * 3 / 2, 1, height, arrowsize, exline, "OAL,LF", "", "");

            fun.dimrot1(dxf, v55, v4, 0, dconms, 1, height, arrowsize, exline, "LPR,LTA", "", "");

            fun.dimrot1(dxf, v13, v11, 0, dconms / 2, 1, height, arrowsize, exline, "TP", "", "");

            fun.dimrot1(dxf, v4, v5, 0, dconms / 2 + (v13.Y + v11.Y) / 2 - (v5.Y + v4.Y) / 2, 1, height, arrowsize, exline, "PDZ", "", "");

            fun.dimrot1(dxf, v48, v51, 90, dconms / 2, 1, height, arrowsize, exline, "DCONMS", "", "");
           
            fun.dimrot1(dxf, v5, v20, -90, dconms, 1, height, arrowsize, exline, "DC", "", "");

            fun.dimrot1(dxf, v53, v46, -90, dconms * 2 / 3, 1, height, arrowsize, exline, "DN", "", "");

            fun.dimrot1(dxf, v49, v47, 180, dconms, 1, height, arrowsize, exline, "LS", "", "");

            fun.dimrot1(dxf, v19, v28, 180, dconms + (v28.Y + v19.Y) / 2 - (v49.Y + v47.Y) / 2, 1, height, arrowsize, exline, "APMX", "", "");

            fun.dimrot1(dxf, v46, v19, 180, dconms * 3 / 2, 1, height, arrowsize, exline, "LU", "", "");

            //2
            fun.dimrot1(dxf, v92, v91, 180, dconms * 2 / 3, 1, height, arrowsize, exline, "PDZ", "", "");

            //3
            fun.dimrot1(dxf, v113, v130, -90, dconms, 1, height, arrowsize, exline, "DC", "", "");

            fun.jdbz2(dxf, new Line(v113, fun.Polar(v113, (180 - tg / 2) * pi / 180, 0.1)), new Line(v130, fun.Polar(v130, (tg / 2 - 180) * pi / 180, 0.1)), oal * 2 + dc / 2, height, arrowsize, exline, "TG", "", "");




            //定义格式，路径导出
            dxf.DrawingVariables.AcadVer = DxfVersion.AutoCad2007;
            dxf.Save(path);


        }

    }
}
